<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    var arr=[3,2,5,1,9];
    //若想给数字从小到大的顺序排列，则可以传入一个函数function(a,b){return a-b};
    var arr1=arr.sort();
    console.log(arr1);
    var arr2=arr.reverse();
    console.log(arr2);

    arr=[3,17,5,8,6];
    arr1=arr.sort();
    console.log(arr1);
    arr1=arr.sort(function(a,b){return a-b});
    console.log(arr1);
    arr2=arr.reverse();
    console.log(arr2);
</script>
</html>